/*
 * print.h
 *
 * Created: 29.7.2013 11:18:32
 *  Author: Ferda
 */ 


#ifndef PRINT_H_
#define PRINT_H_

#include <inttypes.h>
#include <stdarg.h>
#include <avr/pgmspace.h>

#ifndef FORCE_INLINE
	#define FORCE_INLINE inline __attribute__((always_inline))
#endif

//================================================================

typedef void(*WRITE_FUNC)(uint8_t);

//====================================================================
/*
#ifdef __cplusplus
	extern "C" {
#endif
*/

FORCE_INLINE void println(WRITE_FUNC fn) { fn('\r'); fn('\r'); }
FORCE_INLINE void printString(WRITE_FUNC fn, const char *str){ char c; while ((c = *str++) != 0) fn(c); }
FORCE_INLINE void printlnString(WRITE_FUNC fn, const char* str) { printString(fn, str); println(fn); }
FORCE_INLINE void printString_P(WRITE_FUNC fn, const char *str){ char c; while((c = pgm_read_byte_far(str++)) != 0) fn(c); }
FORCE_INLINE void printlnString_P(WRITE_FUNC fn, const char *str) { printString_P(fn, str); println(fn); }

void printUINT32(WRITE_FUNC fn, uint32_t val, uint8_t base); 
void printINT32(WRITE_FUNC fn, uint32_t val, uint8_t base); 


void printfn(WRITE_FUNC fn, const char * str, ...);
void printfnln(WRITE_FUNC fn, const char * str, ...);

void printfn_P(WRITE_FUNC fn, const char *str, ...);
void printfnln_P(WRITE_FUNC fn, const char *str, ...); 

/*
#ifdef __cplusplus
	};
#endif
*/
#endif /* PRINT_H_ */